<template>
  <h1>El-表单组件</h1>
  <el-form style="width: 500px;margin: 0 auto;" label-width="80">
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" v-model="user.username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入密码" show-password v-model="user.password"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio-button label="男" value="1"></el-radio-button>
        <el-radio-button label="女" value="0"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select placeholder="请选择所在地" v-model="user.city">
        <el-option label="北京" value="beijing"></el-option>
        <el-option label="上海" value="shanghai"></el-option>
        <el-option label="广州" value="guangzhou"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.isAdmin"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="reg">点我提交</el-button>
    </el-form-item>
  </el-form>
  <p v-if="isShow">i幅度就i路</p>
  <p v-show="isShow">i幅度就i路</p>
  <button @click="changeStatus">点我切换显示状态</button>
  <h1>题目2</h1>
  <input type="text" placeholder="请将要展示的图片地址粘贴到此处" v-model="imgUrl">
  <img :src="imgUrl" alt="请输入图片路径">
 <ul>
   <li v-for="(item,index) in fru" >
     {{item}}
     <button @click="del(index)">删除</button>
   </li>
 </ul>
</template>

<script setup>
import {ref} from "vue";

const isShow = ref(true);
const changeStatus = () => {
  isShow.value = !isShow.value;
};

const imgUrl = ref('');

const fru = ref([
'苹果',
'香蕉',
    '橘子',
    '桃子'
    ,'西瓜'
]);

const user = ref({
  username: "",
  password: "",
  gender: "",
  city: "",
  isAdmin: false
});

const del=(index)=>{
  fru.value.splice(index,1);
}
const reg = () => {
  console.log(user.value);
};


</script>

<style scoped>

</style>